#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/12/21 20:07
# @Author: hekang
# @Email: 591785757@qq.com
# @File：log_page.py
"""
日志页
"""
from selenium.webdriver.common.by import By
from pages.base_page import BasePage


class Log(BasePage):
    # 定位器
    edit_locator = (  # 定位"修改"
        By.CSS_SELECTOR, "#form1 > table > tbody > tr > td:nth-child(7) > a:nth-child(2)")
    content_locator = (  # 定位"内容"框
        By.CLASS_NAME, "ke-content")
    save_locator = (  # 定位"保存"
        By.CLASS_NAME, "btn-primary")
    look_locator = (  # 定位"查看"
        By.CSS_SELECTOR, "#form1 > table > tbody > tr > td:nth-child(7) > a:nth-child(1)")

    # 点击"查看"
    def log_look(self):
        self.driver.find_element(*self.look_locator).click()

    # 点击"修改"
    def log_edit(self):
        self.driver.find_element(*self.edit_locator).click()

    # 修改"内容"
    def log_content(self, content):
        self.driver.switch_to.frame(0)
        self.driver.find_element(*self.content_locator).clear()
        self.driver.find_element(*self.content_locator).send_keys(content)
        self.driver.switch_to.parent_frame()

    # 点击"保存"
    def log_save(self):
        self.driver.find_element(*self.save_locator).click()
